<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
			"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Complexspiral Demo</title>
<!-- compliance patch for microsoft browsers -->
<!--[if lt IE 7]><script src="../../ie7-standard-p.js" type="text/javascript"></script><![endif]-->
<link rel="stylesheet" title="Shell (Default)" href="shell-bg.css" type="text/css" media="screen">
<link rel="alternate stylesheet" title="Shuttle" href="shuttle-bg.css" type="text/css" media="screen">
<link rel="alternate stylesheet" title="Big Ben" href="bigben-bg.css" type="text/css" media="screen">
<link rel="alternate stylesheet" title="Lightning" href="lightning-bg.css" type="text/css" media="screen">
<link rel="alternate stylesheet" title="Flower" href="flower-bg.css" type="text/css" media="screen">
<style type="text/css">
<!--
body {position: relative; margin: 0; padding: 0;}
div#content {position: absolute; top: 26px; left: 161px; right: 25px;
   color: #EED; font: 13px Verdana, sans-serif; padding: 10px;
   border: solid #FFCC99;}
div#content p {margin: 0 1em 1em;}
div#content h3 {margin-bottom: 0.25em;}
div#links a {display: block; text-align: center; font: bold 1em sans-serif;
   padding: 5px 10px; margin: 0 0 2px; border-width: 0;
   text-decoration: none; color: #FFC;}
div#links a:hover {color: #411;}
h1 {margin: -9px -9px 0.5em; padding: 15px 0 5px; text-align: right; background: #ACE; color: #024; letter-spacing: 0.5em; text-transform: lowercase; font: bold 25px sans-serif; height: 28px; vertical-align: middle; white-space: nowrap;}
dt {font-weight: bold;}
dd {margin-bottom: 0.66em;}
div#content a:link {color: white;}
div#content a:visited {color: #BBC;}
div#content a:link:hover {color: #FF0;}
div#content a:visited:hover {color: #CC0;}
div#links {position: absolute; top: 52px; left: 0; width: 160px; height: 700px; font: 16px Verdana, sans-serif;}
code, pre {color: #EDC; font: 110% monospace;}
-->
</style>
</head>
<body>
<script type="text/javascript" src="../ie7-demo.js"></script>
<div id="links">
<a href="http://www.meyerweb.com/">Home</a>

<a href="http://www.meyerweb.com/eric/css/">Links</a>
<a href="http://www.cnn.com/">Away</a>
<a href="http://www.meyerweb.com/eric/">Eric</a>
<a href="http://www.meyerweb.com/kat/">Kat</a>
<a href="http://www.meyerweb.com/other/">Other</a>
</div>
<div id="content">
<h1>complexspiral demo</h1>
<p>
The page you are viewing right now exists to show off what can be accomplished with pure <a href="http://www.w3.org/TR/REC-CSS1">CSS1</a> and a little teeny piece of <a href="http://www.w3.org/TR/REC-CSS2">CSS2</a> (specifically, the hover effects on hyperlinks).  Remember: as you look this demo over, there is <em>no</em> Javascript here, nor are <em>any</em> PNGs being used, nor do I employ <em>any</em> proprietary extensions to CSS or any other language.  It's all done using straight W3C-recommended markup and styling, all validated, plus a total of four (4) images.  Unfortunately, not every browser supports all of CSS1, and only those browsers which fully and completely support CSS1 will get this right.  Despite some claims to the contrary, IE6/Win's rendering of this page is <strong>not</strong> correct, as it (as well as some other browsers) doesn't correctly support <code>background-attachment: fixed</code> for any element other than the <code>body</code>.  That makes it impossible to pull off the intended effect.  Other browsers may or may not get the effect right.

</p>


<h3>Hands-on: Things to Examine</h3>
<p>
Before you start, make sure you're viewing this page in one of the browsers mentioned above.  Otherwise the descriptions to follow won't match what you see.
</p>
<p>
The first, easiest thing to do is scroll the page vertically.  Notice how the hyperlinks on the left side of the page slide over the background seamlessly, as does the main content area (this blue-backed box right here).  The visual effect should be that the hyperlinks and the main content area have translucent backgrounds, but opaque foregrounds.  They don't, in fact, but that's what it should look like.
</p>
<p>
Try changing the text size and notice how the compositing effect remains consistent.  Then make your browser window really narrow and scroll horizontally.  Again, everything should remain seamless and consistent.  Try hovering over the left-hand links and you should see the background change.  Scroll the page so it's not at its default, change the size of the text, and hover again.  The "compositing" is still seamless as ever.
</p>
<p>
No, I'm not using one or more semi-transparent PNGs for the link and content backgrounds, nor am I employing a half-screen GIF trick.  The entire page is driven by one HTML document containing an embedded stylesheet and no Javascript, one external CSS file, and four JPG images.
</p>

<h3>What the Sam Scratch is goin' on here?!?</h3>
<p>
Glad you asked.  The effect demonstrated here is achieved by using fixed background images, nothing more.  For example, the main-content area (the blue part here) uses the following styles for the default spiral-shell background:
</p>
<pre>
div#content {background: #468 url(shell-blue.jpg) 0 0 no-repeat fixed;}
</pre>
<p>
The above is equivalent to these styles:
</p>
<pre>
div#content {
   background-color: #468;
   background-image: url(shell-blue.jpg);
   background-position: 0 0;
   background-repeat: no-repeat;
   background-attachment: fixed;
   }
</pre>
<p>
The effect of these longer rules is exactly the same; they're just split out into individual background properties for more detailed consideration by you, gentle reader.
</p>

<p>
First, check out the blue-shell image found here: <a href="shell-blue.jpg">url(shell-blue.jpg)</a>.  Then come back to this page and I'll continue with the explanation.  All done?  Great.
</p>
<p>
According to CSS, any background image that is "fixed" using <code>background-attachment: fixed;</code> is fixed with respect to the <strong>viewport</strong>-- <em>not</em> the element with which the image is associated.  So I set the blue-shell background image to be aligned with the top left corner of the browser window (the viewport) with the values given for <code>background-position</code>.  However, the image will only be visible wherever is intersects with the element to which it's been assigned.  Therefore, even though the top left corner of the blue-shell image is aligned with the top left corner of the viewport, we can only see it wherever it intersects with a <code>div</code> that has an <code>id</code> with a value of <code>content</code> (which, again, happens to be the one containing this text).

</p>
<p>
So I set a fixed background for the <code>BODY</code>, the content <code>DIV</code>, and the hyperlinks in both their normal and hovered states.  (I also turned the hyperlinks into block-level elements, thus avoiding the need for tables or other cumbersome markup tricks.)  In any given case of an element's display, we see whatever part of the associated background image intersects with the element.  The rest of the background image remains hidden.
</p>
<p>
And <em>that's</em> how it works.
</p>
<h3>Alternate fun</h3>
<p>

I've associated four additional backgrounds with this page, all of them <code>LINK</code>ed in as alternate stylesheets.  In Netscape 6.x, you can pick them by going to the menu "View" and opening the submenu "Use Stylesheet."  In IE5/Mac, you can pick alternate stylesheets using the "Choose stylesheet" favelet made available at <a href="http://www.favelets.com/">favelets.com</a>.  Either way, picking a stylesheet will cause the browser to switch to using one of the following stylesheets.  Here are links to those stylesheets, so you can see for yourself how similar (and simple!) they are:
</p>
<ul>
<li><a href="shell-bg.css">Shell (Default)</a></li>
<li><a href="shuttle-bg.css">Shuttle</a></li>
<li><a href="bigben-bg.css">Big Ben</a></li>
<li><a href="lightning-bg.css">Lightning</a></li>
<li><a href="flower-bg.css">Flower</a></li>

</ul>
<p>
If you're using a browser that supports alternate stylesheets, use its picking mechanism to switch to any one of the stylesheets you like and do the same scrolling tests as before.  The compositing will remain seamless.  While you're at it, feel free to dig around in this directory and look at the images used for each stylesheet.  I guarantee you that everything used in the display of the "themes" presented here is contained in this directory.
</p>
<h3>I'm not seeing any seamless compositing!</h3>
<p>
Then I'm willing to bet that you're using Internet Explorer for Windows (any version), or possibly Opera (version 6 or earlier).  Neither of these browsers properly support <code>background-attachment: fixed</code> for elements other than <code>body</code>.  In the case of both, images are fixed with respect to the elements that contain them, not the browser window, which is not what CSS1 defines <code>background-attachment: fixed</code> to mean, although browsers are allowed to ignore <code>fixed</code> if they stick to CSS1 (CSS2 requires its implementation for conformance).  And yes, this page uses a strict DOCTYPE, so IE6 is in "<a href="http://msdn.microsoft.com/library/en-us/dnie60/html/cssenhancements.asp">strict mode</a>."  I guess when <a href="http://www.microsoft.com/windows/ie/evaluation/features/default.asp#section5">Microsoft claims 100% CSS1 compliance</a>, they're referring to the CSS1 core (a reduced subset of CSS1) instead of the entirety of the <a href="http://www.w3.org/TR/REC-CSS1">CSS1 specification</a>.  It tends to make me wonder how limited or flawed their "full support" is for other key open specifications, like HTML and DOM.

</p>

<h3>The pros and cons</h3>
<p>
Right off the bat, there's the fact that I've demonstrated something here that no sliced-image tool can provide for you.  The compositing effects that <code>background-attachment: fixed</code> makes possible are without equal in the WYSIWYG world.  Furthermore, if you look in the source you'll see that my left-side hyperlinks are all text, which would make rearranging or rewriting them a snap.  It also lets them adapt to the user's display preferences with a minimum of fuss.
</p>
<p>
While I used pixel widths to position my elements here, I could have used ems or any other measure.  I just used pixels because I felt like it.  I also used positioned elements instead of a table just for kicks, but I could have used a table just as easily.  The result would have been the same, at least in CSS1-conformant browsers.  The key here is the incredible flexibility of layout you can have, and lining up the backgrounds isn't necessary because the browser does it for you.  No more re-slicing your images, or having to edit cumbersome graphic files!
</p>
<p>
In addition, creating new styles for the visited and active states of the hyperlinks requires nothing more than two new background images and a couple of lines of CSS.  That's it!  With a sufficently optimized (or small) background image, you could get each effect while only adding a few kilobytes to your page weight, which might seem like a lot but almost certainly will be less than the overhead incurred with multiple sliced images and the HTTP requests needed to load them in a traditional sliced-image site-- and again I say it: in such sites, you can't have the seamless compositing effect shown here.
</p>
<p>

The drawback, of course, is (as ever) flawed browsers.
</p>
<h3>Image credits</h3>
<ul>
<li>Nautilus shell: scanned by and copyright Eric A. Meyer
<li>Space shuttle: NASA
<li>Big Ben: unknown; downloaded from Usenet
<li>Lightning: unknown; downloaded from Usenet
<li>Flower: unknown; downloaded from Usenet
</ul>

<h3>Return</h3>
<ul>
<li><a href="glassy.html">complex spiral (distorted)</a></li>

<li><a href="demo2.html">complex spiral (devolved)</a></li>
<li><a href="http://www.meyerweb.com/eric/css/edge/index.html">css/edge home</a></li>
</ul>
</div>
</body>
</html>